package com.pengtu.entity.detect;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.pengtu.utils.MathsUtils;

/**
 * Safetyspot.
 */
@Entity
@Table(name = "S_Q_DETECT_SAFETYSPOT")
public class Safetyspot {

	/**
	 * serialVersionUID:TODO
	 * 
	 * @since 1.0.0
	 */

	private static final long serialVersionUID = 1L;
	private String projectId;
	private Integer countF601;
	private Integer passF601;
	private Integer countF602;
	private Integer passF602;
	private Integer countF603;
	private Integer passF603;
	private Integer countF604;
	private Integer passF604;
	private Integer countF605;
	private Integer passF605;
	private Integer countF606;
	private Integer passF606;
	private Integer countF607;
	private Integer passF607;
	private Integer countF608;
	private Integer passF608;
	private Integer countF609;
	private Integer passF609;
	private Integer countF610;
	private Integer passF610;
	private Date reportdate;
	private String remark;
	private SpotReport spotReport;
	private String id;
	private String groupBy;
	private Date createDate; // 创建时间

	public Safetyspot(Long countF601, Long passF601, Long countF602,
			Long passF602, Long countF603, Long passF603, Long countF604,
			Long passF604, Long countF605, Long passF605, Long countF606,
			Long passF606, Long countF607, Long passF607, Long countF608,
			Long passF608, Long countF609, Long passF609, Long countF610,
			Long passF610,String groupBy) {
		this.countF601 = countF601 == null ? null : countF601.intValue();
		this.passF601 = passF601 == null ? null : passF601.intValue();
		this.countF602 = countF602 == null ? null : countF602.intValue();
		this.passF602 = passF602 == null ? null : passF602.intValue();
		this.countF603 = countF603 == null ? null : countF603.intValue();
		this.passF603 = passF603 == null ? null : passF603.intValue();
		this.countF604 = countF604 == null ? null : countF604.intValue();
		this.passF604 = passF604 == null ? null : passF604.intValue();
		this.countF605 = countF605 == null ? null : countF605.intValue();
		this.passF605 = passF605 == null ? null : passF605.intValue();
		this.countF606 = countF606 == null ? null : countF606.intValue();
		this.passF606 = passF606 == null ? null : passF606.intValue();
		this.countF607 = countF607 == null ? null : countF607.intValue();
		this.passF607 = passF607 == null ? null : passF607.intValue();
		this.countF608 = countF608 == null ? null : countF608.intValue();
		this.passF608 = passF608 == null ? null : passF608.intValue();
		this.countF609 = countF609 == null ? null : countF609.intValue();
		this.passF609 = passF609 == null ? null : passF609.intValue();
		this.countF610 = countF610 == null ? null : countF610.intValue();
		this.passF610 = passF610 == null ? null : passF610.intValue();
		this.groupBy = groupBy;
	}
	public Safetyspot(Long countF601, Long passF601, Long countF602,
			Long passF602, Long countF603, Long passF603, Long countF604,
			Long passF604, Long countF605, Long passF605, Long countF606,
			Long passF606, Long countF607, Long passF607, Long countF608,
			Long passF608, Long countF609, Long passF609, Long countF610,
			Long passF610) {
		this.countF601 = countF601 == null ? null : countF601.intValue();
		this.passF601 = passF601 == null ? null : passF601.intValue();
		this.countF602 = countF602 == null ? null : countF602.intValue();
		this.passF602 = passF602 == null ? null : passF602.intValue();
		this.countF603 = countF603 == null ? null : countF603.intValue();
		this.passF603 = passF603 == null ? null : passF603.intValue();
		this.countF604 = countF604 == null ? null : countF604.intValue();
		this.passF604 = passF604 == null ? null : passF604.intValue();
		this.countF605 = countF605 == null ? null : countF605.intValue();
		this.passF605 = passF605 == null ? null : passF605.intValue();
		this.countF606 = countF606 == null ? null : countF606.intValue();
		this.passF606 = passF606 == null ? null : passF606.intValue();
		this.countF607 = countF607 == null ? null : countF607.intValue();
		this.passF607 = passF607 == null ? null : passF607.intValue();
		this.countF608 = countF608 == null ? null : countF608.intValue();
		this.passF608 = passF608 == null ? null : passF608.intValue();
		this.countF609 = countF609 == null ? null : countF609.intValue();
		this.passF609 = passF609 == null ? null : passF609.intValue();
		this.countF610 = countF610 == null ? null : countF610.intValue();
		this.passF610 = passF610 == null ? null : passF610.intValue();
	}

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(length = 48)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(nullable = false, updatable = false, name = "CREATEDATE")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@OneToOne(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
	@JoinColumn(name = "SID")
	public SpotReport getSpotReport() {
		return spotReport;
	}

	public void setSpotReport(SpotReport spotReport) {
		this.spotReport = spotReport;
	}

	public Safetyspot() {
	}

	@Column(name = "PID")
	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "COUNT_F601", precision = 22, scale = 0)
	public Integer getCountF601() {
		return this.countF601;
	}

	public void setCountF601(Integer countF601) {
		this.countF601 = countF601;
	}

	@Column(name = "PASS_F601", precision = 22, scale = 0)
	public Integer getPassF601() {
		return this.passF601;
	}

	public void setPassF601(Integer passF601) {
		this.passF601 = passF601;
	}

	@Transient
	public Double getPassrateF601() {
		Double a = MathsUtils.div("2", getPassF601(), getCountF601(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F602", precision = 22, scale = 0)
	public Integer getCountF602() {
		return this.countF602;
	}

	public void setCountF602(Integer countF602) {
		this.countF602 = countF602;
	}

	@Column(name = "PASS_F602", precision = 22, scale = 0)
	public Integer getPassF602() {
		return this.passF602;
	}

	public void setPassF602(Integer passF602) {
		this.passF602 = passF602;
	}

	@Transient
	public Double getPassrateF602() {
		Double a = MathsUtils.div("2", getPassF602(), getCountF602(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F603", precision = 22, scale = 0)
	public Integer getCountF603() {
		return this.countF603;
	}

	public void setCountF603(Integer countF603) {
		this.countF603 = countF603;
	}

	@Column(name = "PASS_F603", precision = 22, scale = 0)
	public Integer getPassF603() {
		return this.passF603;
	}

	public void setPassF603(Integer passF603) {
		this.passF603 = passF603;
	}

	@Transient
	public Double getPassrateF603() {
		Double a = MathsUtils.div("2", getPassF603(), getCountF603(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F604", precision = 22, scale = 0)
	public Integer getCountF604() {
		return this.countF604;
	}

	public void setCountF604(Integer countF604) {
		this.countF604 = countF604;
	}

	@Column(name = "PASS_F604", precision = 22, scale = 0)
	public Integer getPassF604() {
		return this.passF604;
	}

	public void setPassF604(Integer passF604) {
		this.passF604 = passF604;
	}

	@Transient
	public Double getPassrateF604() {
		Double a = MathsUtils.div("2", getPassF604(), getCountF604(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F605", precision = 22, scale = 0)
	public Integer getCountF605() {
		return this.countF605;
	}

	public void setCountF605(Integer countF605) {
		this.countF605 = countF605;
	}

	@Column(name = "PASS_F605", precision = 22, scale = 0)
	public Integer getPassF605() {
		return this.passF605;
	}

	public void setPassF605(Integer passF605) {
		this.passF605 = passF605;
	}

	@Transient
	public Double getPassrateF605() {
		Double a = MathsUtils.div("2", getPassF605(), getCountF605(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F606", precision = 22, scale = 0)
	public Integer getCountF606() {
		return this.countF606;
	}

	public void setCountF606(Integer countF606) {
		this.countF606 = countF606;
	}

	@Column(name = "PASS_F606", precision = 22, scale = 0)
	public Integer getPassF606() {
		return this.passF606;
	}

	public void setPassF606(Integer passF606) {
		this.passF606 = passF606;
	}

	@Transient
	public Double getPassrateF606() {
		Double a = MathsUtils.div("2", getPassF606(), getCountF606(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F607", precision = 22, scale = 0)
	public Integer getCountF607() {
		return this.countF607;
	}

	public void setCountF607(Integer countF607) {
		this.countF607 = countF607;
	}

	@Column(name = "PASS_F607", precision = 22, scale = 0)
	public Integer getPassF607() {
		return this.passF607;
	}

	public void setPassF607(Integer passF607) {
		this.passF607 = passF607;
	}

	@Transient
	public Double getPassrateF607() {
		Double a = MathsUtils.div("2", getPassF607(), getCountF607(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F608", precision = 22, scale = 0)
	public Integer getCountF608() {
		return this.countF608;
	}

	public void setCountF608(Integer countF608) {
		this.countF608 = countF608;
	}

	@Column(name = "PASS_F608", precision = 22, scale = 0)
	public Integer getPassF608() {
		return this.passF608;
	}

	public void setPassF608(Integer passF608) {
		this.passF608 = passF608;
	}

	@Transient
	public Double getPassrateF608() {
		Double a = MathsUtils.div("2", getPassF608(), getCountF608(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F609", precision = 22, scale = 0)
	public Integer getCountF609() {
		return this.countF609;
	}

	public void setCountF609(Integer countF609) {
		this.countF609 = countF609;
	}

	@Column(name = "PASS_F609", precision = 22, scale = 0)
	public Integer getPassF609() {
		return this.passF609;
	}

	public void setPassF609(Integer passF609) {
		this.passF609 = passF609;
	}

	@Transient
	public Double getPassrateF609() {
		Double a = MathsUtils.div("2", getPassF609(), getCountF609(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Column(name = "COUNT_F610", precision = 22, scale = 0)
	public Integer getCountF610() {
		return this.countF610;
	}

	public void setCountF610(Integer countF610) {
		this.countF610 = countF610;
	}

	@Column(name = "PASS_F610", precision = 22, scale = 0)
	public Integer getPassF610() {
		return this.passF610;
	}

	public void setPassF610(Integer passF610) {
		this.passF610 = passF610;
	}

	@Transient
	public Double getPassrateF610() {
		Double a = MathsUtils.div("2", getPassF610(), getCountF610(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "REPORTDATE", length = 7)
	public Date getReportdate() {
		return this.reportdate;
	}

	public void setReportdate(Date reportdate) {
		this.reportdate = reportdate;
	}

	@Column(name = "REMARK", length = 400)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Transient
	public double getCountF600() {
		return MathsUtils.sum(getCountF601(), getCountF602(), getCountF603(),
				getCountF604(), getCountF605(), getCountF606(), getCountF607(),
				getCountF608(), getCountF609(), getCountF610());
	}

	@Transient
	public double getPassF600() {
		return MathsUtils.sum(getPassF601(), getPassF602(), getPassF603(),
				getPassF604(), getPassF605(), getPassF606(), getPassF607(),
				getPassF608(), getPassF609(), getPassF610());
	}

	@Transient
	public double getPassrateF600() {
		if (getCountF600() == 0) {
			return 0;
		} else {
			return MathsUtils.div("2", getPassF600(), getCountF600(),
					0.01);
		}
	}
	@Transient
	public String getGroupBy() {
		return this.groupBy;
	}
}
